#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# @Project ：project
# @FileName：debugtalk.py
# @IDE     ：PyCharm
# @Author  ：叶鸟翼
# @Time    ：2022/10/20 19:36
# @Desc    ：用户自定义函数
import time
from datetime import datetime, timedelta


def getCurrentTimestamp():
    """获取当前时间戳

    :return:
    :rtype: int
    """
    return int(time.time())


def getCurrentDate():
    """获取当前日期(年-月-日)
    e.g.
        2022-10-21

    :return:
    :rtype: str
    """
    return datetime.now().strftime('%F')


def getCurrentTime():
    """获取当前日期(年-月-日 时-分-秒)
    e.g.
        2022-10-21 12:54:39

    :return:
    :rtype: str
    """
    return datetime.now().strftime('%F %T')


def dateFormatByOffsetWeek(patter: str, offset: int):
    """偏移周

    Commonly used format codes:
        %Y  Year with century as a decimal number
        %m  Month as a decimal number [01,12]
        %d  Day of the month as a decimal number [01,31]
        %H  Hour (24-hour clock) as a decimal number [00,23]
        %M  Minute as a decimal number [00,59]
        %S  Second as a decimal number [00,61]
        %z  Time zone offset from UTC
        %a  Locale's abbreviated weekday name
        %A  Locale's full weekday name
        %b  Locale's abbreviated month name
        %B  Locale's full month name
        %c  Locale's appropriate date and time representation
        %I  Hour (12-hour clock) as a decimal number [01,12]
        %p  Locale's equivalent of either AM or PM
    :param patter: 描述日期和时间格式的模
    :param offset: 偏移周数，正数向未来偏移，负数向历史偏移
    :return:
    :rtype: str
    """
    dt = datetime.now() + timedelta(weeks=offset)
    return dt.strftime(patter)


def dateFormatByOffsetDay(patter: str, offset: int):
    """偏移天

    :param patter: 描述日期和时间格式的模式
    :param offset: 偏移天数，正数向未来偏移，负数向历史偏移
    :return:
    :rtype: str
    """
    dt = datetime.now() + timedelta(days=offset)
    return dt.strftime(patter)


def dateFormatByOffsetHour(patter: str, offset: int):
    """偏移小时

    :param patter: 描述日期和时间格式的模式
    :param offset: 偏移小时，正数向未来偏移，负数向历史偏移
    :return:
    :rtype: str
    """
    dt = datetime.now() + timedelta(hours=offset)
    return dt.strftime(patter)


def dateFormatByOffsetMinute(patter: str, offset: int):
    """偏移分钟

    :param patter: 描述日期和时间格式的模式
    :param offset: 偏移分钟，正数向未来偏移，负数向历史偏移
    :return:
    :rtype: str
    """
    dt = datetime.now() + timedelta(minutes=offset)
    return dt.strftime(patter)


def dateFormatByOffsetSeconds(patter: str, offset: int):
    """偏移秒钟

    :param patter: 描述日期和时间格式的模式
    :param offset: 偏移秒钟，正数向未来偏移，负数向历史偏移
    :return:
    :rtype: str
    """
    dt = datetime.now() + timedelta(seconds=offset)
    return dt.strftime(patter)
